require File.join(File.dirname(__FILE__), 'ptk_helper')
require 'articles_controller'
class ArticlesController; def rescue_action(e); raise e; end; end

class ArticlesControllerTest < ActiveTest::Controller

  fixtures :articles

  # Each Subject has a setup class method, some of which take options
  setup

  # Most dynamic methods default to a convention
  test_should_index_items

  # In ActiveTest::Controller, test_should_* is a synonym for this method:
  test_new_responds_with_new_item

  test_should_show_item :params => { :id => 1 }
  test_show_fails_to_show_item :params => { :id => 19361 }

  # Many options are flexible. Here, you can set params to a method, called during testing:
  test_should_create_item :params => :a_good_article
  
  # You can set params to a proc
  # Unless noted, procs are in the INSTANCE scope -- not CLASS, where you define them
  test_create_fails_to_create_item :params => proc { a_good_article.merge(:body => nil) }

  # Another example, this time directly defining the hash
  test_should_edit_item :params => proc {{ :id => articles(:boring_article).id }}
  
  # Typical situations...
  test_edit_fails_to_edit_item :params => { :id => 19361 }

  test_should_update_item :params => proc { a_good_article.merge(:body => "flibble") }
  test_update_fails_to_update_item :params => { :id => 19361 }

  protected
  # return a hash for parameters
  def a_good_article
    return :article => { :title => "And now...", :body => "for something completely different" }
  end
end
